package com.dtwave.eureka.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dtwave.eureka.entity.UserWx;
import com.dtwave.eureka.entity.dto.UserWxDto;
import com.dtwave.eureka.mapper.UserWxMapper;
import com.dtwave.eureka.service.IUserWxService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 用户微信信息表 服务实现类
 * </p>
 *
 * @author dtwave
 * @since 2019-05-27
 */
@Service
public class UserWxServiceImpl extends ServiceImpl<UserWxMapper, UserWx> implements IUserWxService {

    @Autowired
    private UserWxMapper userWxMapper;

    @Override
    public List<UserWxDto> findSome() {
        List<UserWxDto> result = new ArrayList<>();
        QueryWrapper<UserWx> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(UserWx::getIsDeleted, 1);
        List<UserWx> list = userWxMapper.selectList(queryWrapper);
        if (!CollectionUtils.isEmpty(list)) {
            list.forEach(l -> {
                UserWxDto dto = new UserWxDto();
                BeanUtils.copyProperties(l, dto);
                result.add(dto);

            });
        }
        return result;
    }
}
